# It defines the following variables
#  SPC_INCLUDE_DIRS - include directories for FooBar
#  SPC_LIBRARY_DIRS - the path to the libraries
#  SPC_LIBRARIES    - libraries to link against
#  SPC_DEFINITIONS  - the definitions used to compile SPC/PCL
#  CEREAL_IS_INTERNAL  - if spc was compiled with an "internal version" of cereal or, if FALSE was a system-wide
#  SPC_WITH_PCL - if spc was compiled with PCL

set(SPC_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
set(SPC_LIBRARY_DIRS "@CONF_LIBRARY_DIRS@")
set(SPC_LIBRARIES "@SPC_LIBRARIES@" )
set(SPC_DEFINITIONS "@SPC_DEFINITIONS@")
set(SPC_ADDITIONAL_CMAKE_PATHS "@SPC_ADDITIONAL_CMAKE_PATHS@")

LIST(APPEND CMAKE_MODULE_PATH "${SPC_ADDITIONAL_CMAKE_PATHS}")

#set(SPC_MINIGLOG "@SPC_MINIGLOG@")

set(CEREAL_IS_INTERNAL @CEREAL_IS_INTERNAL@)

set(SPC_WITH_PCL @SPC_WITH_PCL@)

get_filename_component(SPC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include("${SPC_CMAKE_DIR}/SPCTargets.cmake")

if (${CEREAL_IS_INTERNAL})
    message("cereal is internal")
    set(SPC_INCLUDE_DIRS "${SPC_INCLUDE_DIRS}" "@CONF_CEREAL_INCLUDE_DIRS@")
else()
    ## here we should use a find_package for finding the system' cereal lib
    ## nothing for now. It is a TODO.
endif()

    set(SPC_INCLUDE_DIRS "${SPC_INCLUDE_DIRS}" "@CONF_NANOFLANN_INCLUDE_DIRS@")


#if (SPC_MINIGLOG)
#    message("SPC is using the miniglog version from ceres-solver instead that a real glog!")
#    #we add the miniglog dir to the list of the spc-include-dirs
    set(SPC_INCLUDE_DIRS "${SPC_INCLUDE_DIRS}" "@CONF_EASYLOGGINGPP_INCLUDE_DIRS@")
#endif()

if (SPC_WITH_PCL)
    # we find pcl for you
    find_package(PCL 1.7 REQUIRED)
    include_directories(${PCL_INCLUDE_DIRS})
    message("${PCL_INCLUDE_DIRS}")
    link_directories(${PCL_LIBRARY_DIRS})
    add_definitions(${PCL_DEFINITIONS})

    list(APPEND SPC_INCLUDE_DIRS ${PCL_INCLUDE_DIRS})
    list(APPEND SPC_LIBRARY_DIRS ${PCL_LIBRARY_DIRS})
    list(APPEND SPC_LIBRARIES ${PCL_LIBRARIES})
    list(APPEND SPC_DEFINITIONS ${PCL_DEFINITIONS})

else() # need to find boost and eigen by itself
    find_package(Eigen3 REQUIRED)
    include_directories(${EIGEN3_INCLUDE_DIR})

    if(WIN32)
        # also boost! please use static libs as def on win so that we dont have to move boost libs along with the app
        set(Boost_USE_STATIC_LIBS   ON)
    endif()

    set(Boost_USE_MULTITHREADED ON)
    find_package(Boost COMPONENTS filesystem system REQUIRED)
    include_directories(${Boost_INCLUDE_DIRS})
endif()




